Get access-token[AccessToken]

AccessToken

Get access-token

Access-token value is a value generated according to the user name and password to distinguish other users.

Token may expire at any time. It is recommended to obtain the token once every time you use the script to execute.

Request address

POST
http://OmsAddress/app/newoms.php/webservice/token?cmd=10000&ip-type=webservicerest

POST request parameter description

Parameter nameArray typeDescriptionWhether the field is requiredRemarks
usernamestringUser NameYes
passwordstringUser PasswordYes
register_typeintegerAccount registration method. 1: User registered using a password 2: User authenticated by webserviceNoThe default value is the login method of the current OMS
authtypeinteger0: OA login token verification, 1: OA login password verificationNoOA login is no longer supported. This parameter does not need to be filled in. Please use webservice user authentication

Data Parameters

Use json format to represent the record related information. The following is an example:

{
    "username": "tcaplus",
    "register_type": 1,
    "password": "tcaplus"
}

Return Syntax

Return Parameter Description

Field nameData typeDescriptionRemarks
codeinteger0 means a successful return; non-0 means an error return.
errorstringError message when code is not 0
tokenstringToken value of the specified user obtained when the code is 0

Request Example

Send A Request through the Curl Method

curl -H “Content-type: application/json” -X “POST” -d ’{
    “username”: “tcaplus”,
    “register_type”: 1,
    “password”: “tcaplus”
}’ ‘http://omsaddress/app/newoms.php/webservice/token?cmd=10000&ip-type=webservicerest’

Return Example

Successful Return Example

Status of http request = 200

{
    "code": 0,
    "error": "",
    "token": "081dcfbc6f804d9a9fce29fc2f50076486fff972"
}

Failed Return Example

Status of http request != 200

{
    "source_ip": "ip:10.29.89.51 not in whitelist"
}
{
    "code": 1,
    "error": "user name does not exist"
}